import React from 'react';
import { Table, Button } from 'antd';

const UserList = () => {
  // 模拟用户数据
  const data = [
    { id: 1, name: '张三', age: 20, gender: '男' },
    { id: 2, name: '李四', age: 25, gender: '女' },
    { id: 3, name: '王五', age: 30, gender: '男' },
  ];

  const handleEdit = (id) => {
    // 根据id进行编辑操作，跳转到编辑页面
    console.log('编辑用户，id为：', id);
  };

  const columns = [
    { title: 'ID', dataIndex: 'id' },
    { title: '姓名', dataIndex: 'name' },
    { title: '年龄', dataIndex: 'age' },
    { title: '性别', dataIndex: 'gender' },
    {
      title: '操作',
      render: (text, record) => (
        <Button type="link" onClick={() => handleEdit(record.id)}>
          编辑
        </Button>
      ),
    },
  ];



  return (
    <div>
      <h2>用户列表</h2>
      <Table dataSource={data} columns={columns} />
    </div>
  );
};

export default UserList;
